import Request from 'luch-request'
import {finishRequest, startRequest} from "@/request/util/tool";
import {RequestMonitor} from "@/request/util/RequestMonitor";

const http = new Request({
    baseURL: 'http://192.168.110.174:9000',
    header:{
        'Content-Type': 'application/json;charset=UTF-8',
    }
});

const rm=new RequestMonitor()

//请求拦截器
http.interceptors.request.use((config) => {
    startRequest(rm,config)
    return config;
})

// 响应拦截器
http.interceptors.response.use((res) => {
    finishRequest(rm,res.config)
    return res;
},(err)=>{
    finishRequest(rm,err.config)
})

export {http}